package com.example.lwx;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class MyHelper extends SQLiteOpenHelper {
        public MyHelper(@Nullable Context context) {
            super(context, "user_data", null, 2);  //创建对象时，会调用构造方法创建数据库test.db
        }

        @Override
        public void onCreate(SQLiteDatabase db) {
            String sql="create table user(id integer primary key autoincrement,name varchar(16),sex varchar(2),tel varchar(11))";
            db.execSQL(sql);   //创建表information,三个字段_id,name,tel
        }

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

        }
}
